<div id="MenuViewModel">

	<!-- NavBar -->
	<div class="navbar navbar-default navbar-fixed-top">
		<div class="container">
	    	<div class="navbar-header">
	        	<a href="/" class="navbar-brand">Fútbol</a>
	          	<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
	            	<span class="icon-bar"></span>
	            	<span class="icon-bar"></span>
	            	<span class="icon-bar"></span>
	        	</button>
	        </div>
	        <div class="navbar-collapse collapse" id="navbar-main">
	        	<?php if( $this->user ){ ?>
	        	<ul class="nav navbar-nav navbar-left">
	            	<li class="dropdown">
		                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
		                	<?=$this->currentTournament['name']?> <span class="caret"></span>
		                </a>
		                <ul class="dropdown-menu" role="menu">
		                	<?php foreach( $this->tournaments as $t ){ ?>
		                		<li>
		                			<a href="/tournamentManagement/setCurrentTournament/idTournament/<?=$t['idTournament']?>">
		                				<?=$t['name']?> <span style="font-size: 12px;">(<?=$t['points']?>)</span> 
		                			</a>
		                		</li>
							<?php } ?>	
							<li style="font-style: italic;">
								<a href="/tournamentManagement"><?=Yii::t( 'site', 'New tournament' )?>...</a>
							</li>
		                </ul>
	              	</li>
	                <li><a href="/match"><?=Yii::t( 'site', 'Matches' )?></a></li>    
	          	</ul>
	          	<?php } ?>
	         	<ul class="nav navbar-nav navbar-right">
	            	<!-- <li><a href="/">How to play?</a></li>  -->
	            	<?php if( $this->user ){ ?>
	            	<li>
	            		<a href="/site/logout"> <?php echo Yii::t( 'menu', 'Log out' ); ?> </a>
	            	</li>
	            	<?php }else{ ?>
	            	<li>
	            		<a href="javascript:void(0)" data-bind="click: displayLogin">
	            			<?php echo Yii::t( 'menu', 'Log in' ); ?></a>
	            	</li>
	            	<?php } ?>
	          	</ul>
	    	</div>
		</div>
	</div>
	<!-- /NavBar -->
	
	<!-- Login form -->
	<div class="login-container">
		<form id="login_form" method="post" role="form" data-toggle="validator">
			<table>
				<tr>
					<td colspan="2">
						<div id="error-login" class="alert alert-dismissable alert-danger" style="margin-bottom: 10px;">
			                <button type="button" class="close" data-dismiss="alert" style="right: 0px;">×</button>
			                <span></span>
			            </div>
					</td>
					<td></td>
				</tr>
				<tr>
					<td>
						<div class="form-group">
				        	<input id="login-username" class="form-control" type="text" value="" 
				        		placeholder="<?php echo Yii::t( 'menu', 'Username' ); ?>"/>
				        </div>
			        </td>
			        <td>
						<div class="form-group">
				        	<input id="login-password" class="form-control" type="password" value="" 
				        		placeholder="<?php echo Yii::t( 'menu', 'Password' ); ?>"/>
				        </div>
					</td>
					<td>
						<button class="btn btn-default" id="login-submit" data-bind="click: login">
							<?php echo Yii::t( 'menu', 'Join' ); ?>
						</button>
					</td>
				</tr>
			</table>
		</form>
	</div>
	<!-- /Login form -->
	
</div>

<script src="/public/js/MenuViewModel.js" type="text/javascript"></script>
<script>
	var menuViewModel = new MenuViewModel();
	$( document ).ready( function(){ ko.applyBindings( menuViewModel, document.getElementById( 'MenuViewModel' ) ); } );
</script>
